﻿package com.addcn.texas.view.components
{		
	import com.addcn.texas.utils.NumberFormat;
	import flash.display.MovieClip;
	import flash.display.Sprite;		
	import flash.text.TextField;
	
	public class FriendItem extends MovieClip 
	{
		private var _id : uint;
		private var _name: String;
		private var _gold: uint;
		private var _state: String = "out";
		
		function FriendItem(r_id:int, r_name:String, r_gold:int,r_state : int) : void
		{
			this._id = r_id;
			this._name = r_name;
			this._gold = r_gold;
			this["NickName"].text = String(r_name) ;
			if(r_state == 1){
				this["State"].text = "游戲中";			
			}else {
				this["State"].text = "空閑";			
			}
			var _format: NumberFormat = new NumberFormat();				
			this["Gold"].text = "$"+_format.format(r_gold, true);		
			_dbClickEnabled();			
		}
		
		public function get id(): int
		{
			return this._id;
		}
		
		public function setPhoto(r_pic : Object) : void
		{
			if(r_pic){
				this["FriendPhoto"].addChild(r_pic);
			}
		}		
		
		private function _dbClickEnabled() : void
		{
			this["NickName"].doubleClickEnabled = true;
			this["Gold"].doubleClickEnabled = true;
			this["State"].doubleClickEnabled = true;
			this["BackGround"].doubleClickEnabled = true;
			this["FriendPhoto"].doubleClickEnabled = true;			
		}		
		
		public function over() : void
		{
			this["BackGround"].gotoAndStop("over");
			this._state = "over";
		}
		public function out() : void
		{
			this["BackGround"].gotoAndStop("out");
			this._state = "out";
		}
		public function click() : void
		{
			this["BackGround"].gotoAndStop("click");
			this._state = "click";
		}
		public function get state() : String
		{
			return this._state;
		}
			
		
	}
	
}